// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main  implements Runnable {
    private int ticket=100;

    public static void main(String[] args) {
        Main m=new Main();
        new Thread(m).start();
        new Thread(m).start();
        new Thread(m).start();

    }

    @Override
    public void run() {
        while(true)
        {

            synchronized (this) {
                if(ticket<0)
                    return;
                System.out.println(Thread.currentThread().getName() + "--> 还剩下：" + ticket + "张票");
            }
            ticket--;
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

        }
    }
}